﻿using BootstrapBlazor.Components;
using BPM.Web.Shared.Data;
using BPM.Web.Shared.Extensions;
using BPM.Web.Shared.Dependencies;
namespace BPM.Web.Shared.Service;

[Scoped(typeof(ISysConfigService))]
public class SysConfigService : BaseService, ISysConfigService
{
    private readonly IConfigClient _configClient;
    public SysConfigService(IConfigClient configClient, ToastService toast) : base(toast)
      => _configClient = configClient;

    public Task<bool> AddAsync(SysConfig input)
        => ExecuteAsync(_configClient.AddAsync(input.Adapt<AddConfigInput>()));

    public Task<bool> DeleteAsync(IEnumerable<SysConfig> input)
        => DeleteAsync(input.Adapts<SysConfig, DeleteConfigInput>().Select(x => _configClient.DeleteAsync(x)));

    public Task<QueryData<SysConfig>> PageAsync(ConfigPageInput input)
        => QueryAsync(_configClient.PageAsync(input));

    public Task<bool> EditAsync(SysConfig input)
        => ExecuteAsync(_configClient.EditAsync(input.Adapt<UpdateConfigInput>()));
}

